﻿using System;
using System.Collections.Generic;

namespace CSharpConsoleTestSolution.Bean {
    public partial class Person {
        public readonly string Name;
        public int Score;
        // public int Id{ get; }            //没有 set 方法, 和↓效果一样
        public int Id{ get; private set; }  //private set;

        public Person(string name) {
            this.Name = name;
        }

        public static List<Person> GetMarry(Person p1, Person p2) {
            var people = new List<Person> {
                p1,
                p2
            };
            for (var i = 0; i < 3; i++) {
                var person = new Person(p1.Name + " & " + p2.Name + "'s child");
                people.Add(person);
            }

            return people;
        }

        /*
         * 将GetMarry()方法名替换成: operator +
         * 定义 operator 的方法, 必须是 "public static"
         * 说明在C#中, 操作符就是方法的简记法
         */
        public static List<Person> operator +(Person p1, Person p2) {
            return GetMarry(p1, p2);
        }

        public static void PrintHelloStatic() {
            Console.WriteLine("Hello Person Static!");
        }

        public void PrintHello() {
            Console.WriteLine("Hello Person!");
        }
    }
}